package cn.muqingfeng.util;

import java.util.List;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class FavCache {
	private static final String FILE_NAME = ".fav.xml";

	public static final void addFav(Context context, String uid, String tid) {
		SharedPreferences preferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putBoolean(uid + "_" + tid, true);
		editor.commit();
	}

	public static final boolean isFaved(Context context, String uid, String tid) {
		SharedPreferences preferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
		return preferences.getBoolean(uid + "_" + tid, false);
	}

	public static final void addFav(Context context, String uid, List<String> tids) {
		if (tids == null || tids.isEmpty())
			return;
		SharedPreferences preferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		for (String tid : tids) {
			editor.putBoolean(uid + "_" + tid, true);
		}
		editor.commit();
	}
}
